{include file="common/_meta" /}
<title>幻灯片添加</title>
<meta name="keywords" content="李志立，lizhilimaster@163.com">
<meta name="description" content="李志立，lizhilimaster@163.com">
</head>
<body>
	<div class="page-container">
		<form action="" method="post" class="form form-horizontal" id="form-category-add" enctype="multipart/form-data">

					
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">查询字段：</label>
						<div class="formControls col-xs-9 col-sm-9">
							<input id="cha" type="text" class="input-text" value="" placeholder="请输入要查询字段" style="width: 60%;">
							<button class="btn btn-secondary radius" onclick="chaxun()" type="button">点击查询</button>
						</div>
					</div>
					<div style="margin: 55px;"></div>
					<div style="display: none;" class="row cl lizhili">
						<label class="form-label col-xs-2 col-sm-2">是否覆盖数据：</label>
						<div class="formControls col-xs-5 col-sm-5">
							<div class="switch">
								<input name="is_fu" type="checkbox" />
							 </div>
						</div>
						
					</div>
					<div style="display: none;" class="row cl lizhili">
						<label class="form-label col-xs-2 col-sm-2">表中文：</label>
						<div class="formControls col-xs-2 col-sm-2">
							<input type="text" name="cn_name" class="input-text" value="" placeholder="表中文名称" >
						</div>
						<label class="form-label col-xs-1 col-sm-1">表英文：</label>
						<div class="formControls col-xs-2 col-sm-2">
							<input type="text" name="en_name" id="en_name" class="input-text" value="" placeholder="表英文名称" >
						</div>
					</div>
					<div id="main">
						
					</div>
					<div style="display: none;" class="row cl lizhili">
						<div class="col-9 col-offset-2">
							<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
						</div>
					</div>

		</form>
	</div>
	{include file="common/_footer" /}
	<style type="text/css">
		.li123 {
			line-height: 30px;
			background: burlywood;
			display: inline-block;
			vertical-align: middle;
			padding: 0 8px;
		}
		.lizhili-icon{
			padding: 5px 8px;
			margin: 0 8px;
			font-size: 22px;
			background-color: #F2F2F2;
		}
	</style>
	<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/jquery.validate.js"></script>
	<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/validate-methods.js"></script>
	<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/messages_zh.js"></script>
	<script type="text/javascript">
		$(function() {
			$('.skin-minimal input').iCheck({
				checkboxClass: 'icheckbox-blue',
				radioClass: 'iradio-blue',
				increaseArea: '20%'
			});
			let wo=$("#form-category-add").validate({
				rules: {

				},
				submitHandler:function(form) {
					$("input[type=\"submit\"]").addClass('disabled').attr("disabled",true);
					var index = layer.load(1, {
						shade: [0.1,'#fff'] //0.1透明度的白色背景
					});
					setTimeout(()=>{
						$("input[type=\"submit\"]").removeClass('disabled').attr("disabled",false);
						layer.close(index);
					},1000)
					form.submit();
				}
			});
		});
		function chaxun(){
			if(!$('#cha').val()){
				layer.msg('字段不能为空', {
					icon: 5,
					time: 1000
				});
				return
			}
			$.post(
			"{:url('pilot/ajax')}", {
				id: $('#cha').val(),
				type: 'demo_cha',
			},
			function(res) {
				if(res.code==1){
					$('.lizhili').show()
					$('#en_name').val($('#cha').val())
					let html='';
					for (let s of res.data) {
						if(s.Field=='sort' || s.Field=='isopen' || s.Field=='text'){
							html+='<input type="hidden" class="input-text" value="'+s.Field+'" name="name[]">';
						}
						if(s.Field!='update_time' && s.Field!='id' && s.Field!='isopen' && s.Field!='sort' && s.Field!='text' && s.Field!='delete_time'){
						html+=`
						<div class="row cl">
							<label class="form-label col-xs-2 col-sm-2">表字段：</label>
							<div class="formControls col-xs-1 col-sm-1">
								<input type="text" class="input-text" value="${s.Field}" name="name[]">
							</div>
							<div class="formControls col-xs-2 col-sm-2">
								<input type="text" class="input-text" placeholder="中文名称" value="" name="zh_name[]">
							</div>
							<div class="formControls col-xs-6 col-sm-6 skin-minimal">
								<div class="check-box">
								    <label><input name='is_bu[${s.Field}]' type="checkbox"> 是否不显示</label>
								</div>
								<div class="check-box">
								    <label><input name='is_so[${s.Field}]' type="checkbox"> 是否搜索</label>
								</div>
								<div class="check-box">
								    <label><input name='is_bi[${s.Field}]' type="checkbox"> 是否必填</label>
								</div>
								<div class="check-box">
								    <label><input name='is_file[${s.Field}]' type="checkbox"> 是否上传图片</label>
								</div>

								<span class="select-box" style="display: inline-block;width: 120px">
								  <select class="select" size="1" name="type[]">
									<option value="1" selected>文本输入框</option>
									<option value="2">数字输入框</option>
									<option value="3">时间输入框</option>
									<option value="4">多行输入框</option>
<!--									<option value="5">富文本</option>-->

								  </select>
								</span>
							</div>
						</div>`;
						
						}
					}
					$('#main').html(html)
				}else{
					layer.msg('查询数据库错误', {
						icon: 5,
						time: 1000
					});
				}
			});
		}
	</script>
</body>
</html>
